#ifndef SCHEDULER_H_
#define SCHEDULER_H_

#include "ses_common.h"



/*
 * A scheduler for scheduling tasks with a given delay.
 *
 * Tasks can be added with function pointers and a delay (expire) value. Every
 * update the expire value gets decremented. Tasks that are expired will be
 * executed. After that, it is removed from the scheduler.
 *
 * Once started, the scheduler_run() method will run always, updating the
 * tasks in the scheduler ever 1ms.
 */



#define SCHEDULER_ENTRIES	20



/* Type of function pointer for tasks */
typedef void (*task_t)(void);



/*
 * Initializes the task scheduler.
 */
void scheduler_init();

/*
 * Runs scheduler in an infinite loop.
 */
void scheduler_run();

/*
 * Adds new task to the scheduler. A scheduled task is executed once after the
 * given time period.
 *
 * @param task		valid pointer to task
 * @param expire	time period
 */
bool scheduler_add( task_t task, uint16_t expire);

/*
 * Removes a timer task from the scheduler.
 *
 * @param task	pointer to timer
 */
void scheduler_remove(task_t task);



#endif /* SCHEDULER_H_ */
